package HomeWork4;

import sun.misc.IOUtils;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class StreamTeat {
    public static void main(String[] args) {
        Boolean flag=true;
        ArrayList<String> strings = new ArrayList<>();
        Scanner scanner = new Scanner(System.in);
        while (flag)
        {
            String next = scanner.next();
            if (next.equalsIgnoreCase("end")){
                flag=false;
            }else {
                strings.add(next);
            }

        }
        Collections.sort(strings, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o2.compareTo(o1);
            }
        });
        PrintStream printStream=null;
        try {
            printStream = new PrintStream(new FileOutputStream("D:\\大数据作业\\zhao-zheles-code-warehouse\\code\\第四模块\\验证资料\\abc.txt", true));
            for (String string : strings) {
                printStream.println(string);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }finally {
            printStream.close();
        }


    }
}
